package no.ntnu.fp.console;

import acm.program.ConsoleProgram;

@SuppressWarnings("serial")
public class Calendar extends ConsoleProgram {
	Options options;
	String userLoggedIn;
	
	public void init() {
		options = new Options(this);
	}
	
	public void run() {
		boolean wantToLogin = options.welcomeWantToLogIn();
		if (!wantToLogin) {
			options.exit();
		}
		
		userLoggedIn = options.logIn();
		options.setCurrentUser(userLoggedIn);

		while (options.hasMessages(userLoggedIn)) {
			options.showOfflineMessages(userLoggedIn);
			options.showUserAppointments(userLoggedIn);
		}
		
		if (options.hasMessageToMeetingLeader(userLoggedIn)) {
			options.retrieveMessage(userLoggedIn);
		}
		
		if (options.hasMessage(userLoggedIn)) {
			options.showMessage(userLoggedIn);
		}
		
		while (true) {
			options.printMenu();
		}
	}
}
